//
//  NormalSettingTableViewController.m
//  糗事百科
//
//  Created by 奚超明 on 16/6/7.
//  Copyright © 2016年 奚超明. All rights reserved.
//

#import "NormalSettingTableViewController.h"
#import "VedioPlayTableViewController.h"
#import "PictureTableViewController.h"

@interface NormalSettingTableViewController ()
/** 标题数组 */
@property (nonatomic, strong) NSMutableArray *titleArr;
/** 副标题数组 */
@property (nonatomic, strong) NSMutableArray *subTitleArr;

@end

@implementation NormalSettingTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 界面设置
    [self setupTableView];
}

#pragma mark - 设置界面
- (void)setupTableView
{
    // 标题
    self.navigationItem.title = @"常规";
    
    self.tableView = [[UITableView alloc] initWithFrame:self.tableView.frame style:UITableViewStyleGrouped];
}

#pragma mark - 行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.titleArr.count;
}

#pragma mark - 返回cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"NormalSettingTableViewCell"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"NormalSettingTableViewCell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.textLabel.text = self.titleArr[indexPath.row];
    cell.detailTextLabel.text = self.subTitleArr[indexPath.row];
    cell.textLabel.textColor = kRGBColor(118, 118, 136);
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

#pragma mark - 点击cell
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) { // 点击了视频播放选项
        VedioPlayTableViewController *vedioPlayVC = [[VedioPlayTableViewController alloc] init];
        [self.navigationController pushViewController:vedioPlayVC animated:YES];
    } else { // 点击了图片加载选项
        PictureTableViewController *pictureVC = [[PictureTableViewController alloc] init];
        [self.navigationController pushViewController:pictureVC animated:YES];
    }
}

#pragma mark - 懒加载
- (NSMutableArray *)titleArr
{
    if (!_titleArr) {
        _titleArr = [@[@"视频播放", @"图片加载"] mutableCopy];
    }
    return _titleArr;
}

- (NSMutableArray *)subTitleArr
{
    if (!_subTitleArr) {
        _subTitleArr = [@[@"仅WIFI", @"自动"] mutableCopy];
    }
    return _subTitleArr;
}
@end
